package com.javakc.mes.monthly.service.iml;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.javakc.mes.annual.entity.Annual;
import com.javakc.mes.monthly.entity.Monthly;
import com.javakc.mes.monthly.mapper.MonthlyMapper;
import com.javakc.mes.monthly.service.MonthlyService;
import com.javakc.servicebase.config.InstructionQuery;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

@Service
public class MonthlyServiceImpl extends ServiceImpl<MonthlyMapper, Monthly> implements  MonthlyService {

    @Override
    public void findPageMonthlyPage(Page<Monthly> monthlyPage, InstructionQuery instructionQuery) {
        QueryWrapper<Monthly> queryWrapper = new QueryWrapper<>();
        if(!ObjectUtils.isEmpty(instructionQuery)){
            if(!ObjectUtils.isEmpty(instructionQuery.getName())){
                queryWrapper.like("name",instructionQuery.getName());
            }
            if (!ObjectUtils.isEmpty(instructionQuery.getBeginDate())) {
                queryWrapper.ge("gmt_create", instructionQuery.getBeginDate());
            }
            if (!ObjectUtils.isEmpty(instructionQuery.getEndDate())) {
                queryWrapper.lt("gmt_create", instructionQuery.getEndDate());
            }
        }
        queryWrapper.orderByDesc("gmt_create");
        baseMapper.selectPage(monthlyPage,queryWrapper);
    }
}
